package cn.xmoit.util;

import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.storage.file.FileRepositoryBuilder;

import java.io.IOException;
import java.nio.file.Paths;

public class JGitUtils {

	public static Git open(String dir) {
		Git git = null;
		try {
			Repository repository = new FileRepositoryBuilder().setGitDir(Paths.get(dir, ".git").toFile()).build();
			git = new Git(repository);
		}
		catch (IOException e) {
			e.printStackTrace();
		}
		return git;
	}

}
